import Axios from "./../utils/axios";
import api from "@/api";


function getOrderList(currentPage, pageSize) {
    return Axios.post(api.order.GetOrderList,
        JSON.stringify({ currentPage, pageSize }));
}
//筛选
function getSearchObjTwo(orderId, createTime) {
    return Axios.post(api.order.GetOrderList,
        { orderId, createTime });
}
function getstate(data) {
    return Axios.post(api.order.GetOrderList,
        JSON.stringify(data));
}
//详情
function getOrderDetailList(id) {
    return Axios.get(api.order.GetOrderDetailById + `/${id}`);
}
//关闭订单
function closeOrder(id) {
    return Axios.put(api.order.CloseOrder + `/${id}`)
}
//确认订单
function confirmOrder(id) {
    return Axios.put(api.order.ConfirmOrder + `/${id}`)
}
//批量确认订单
function batchconfirmOrder(data) {
    return Axios.put(api.order.BatchConfirm, data)
}
// //查库存
// function getSkuById(id) {
//     return Axios.get(api.order.GetSkuById + `/${id}`);
// }
//查库存
function getSkuById(id) {
    return Axios.get(api.order.GetSkuById + `/${id}`);
}
//查状态数
function btngetCount() {
    return Axios.post(api.order.BtnGetCount,);
}
//修改
function OderUpdate(data) {
    return Axios.put(api.order.UpdateOrders, data);
}

//请求退换货列表数据
function getOrderApplyList(currentPage,pageSize) {
    return Axios.post(api.order.GetOrderApplyList,{currentPage,pageSize})
}

//数据状态分类筛选请求
function stateClassification(refundSts){
    return Axios.post(api.order.GetOrderApplyList,{refundSts})
}

//发起筛查请求
function getSearchObj(orderId,userName) {
    return Axios.post(api.order.GetOrderApplyList,{orderId,userName})
}

//查看详情页接口
function getfindById(refundId){
    console.log(api.order.GetfindById+`/${refundId}`);
    return Axios.get(api.order.GetfindById+`/${refundId}`)
}

// 发起请求  批量删除已拒绝项
function delbatchRemoveById(ids){
    return Axios.delete(api.order.DelbatchRemoveById,{data:ids})
}

//同意退货
function putConfirmRefundBy(refundId,handlingOpinions,remarks){
    return Axios.put(api.order.PutconfirmRefundBy,{refundId,handlingOpinions,remarks})
}

//拒绝退货
function putRefuseRefundBy(refundId,handlingOpinions,remarks){
    return Axios.put(api.order.PutrefuseRefundBy,{refundId,handlingOpinions,remarks})
}

//修改处理意见
function putUpdateRefuse(refundId,remarks){
    return Axios.put(api.order.PutupdateRefuse,{refundId,remarks})
}

// 获取数据计量条数
function getExchangeCount(){
    return Axios.get(api.order.GetExchangeCount,)
}

function getAllRefund(currentPage, pageSize,refundSts,orderId,userName,handelTime,sort) {//获取退款订单
    return Axios.post(api.order.getAllRefund, {
        currentPage,
        pageSize,
        refundSts,
        orderId,
        userName,
        handelTime,
        sort
    })
}
function refuseRefundById(handlingOpinions,refundId,remarks) {//拒绝退款
    return Axios.put(api.order.refuseRefundById,{
        handlingOpinions,
        refundId,
        remarks
    })
}
function confirmRefundById(handlingOpinions,refundId,remarks) {//确认退款
    return Axios.put(api.order.confirmRefundById,{
        handlingOpinions,
        refundId,
        remarks
    })
}
function seachDetailsById(id) {//查看详情
    return Axios.get(api.order.seachDetailsById + `/${id}`
    )
}
function updateRefuseById(refundId,remarks) {//修改意见
   return Axios.put(api.order.updateRefuseById,{
        refundId,
        remarks
   })
}
function batchRemove(ids) {//批量删除已拒绝
  return Axios.delete(api.order.batchRemove,{ data:ids })
}
function getOrderReturns(currentPage,pageSize) {
    return Axios.post(api.order.orderReturns,{
        currentPage,
        pageSize
    })
}
//退换原因批量删除
function deleteByIds(array){
    console.log("service",array);
    return Axios.post(api.order.deleteByIds,array)
}
//添加退换原因
function addCauseList(orderreturnsId,cause,ordering,initiated){
    return Axios.post(api.order.addCause,{
        orderreturnsId,
        cause,
        ordering,
        initiated
    })
}
//修改退款原因
function updataBUId(orderreturnsId,cause,ordering,initiated){
    return Axios.post(api.order.update,{
        orderreturnsId,
        cause,
        ordering,
        initiated,
    })
}
//获取退款列表的数据统计
function getRefundCount(){
  return Axios.get(api.order.getRefundCount)
}
export default {
    getAllRefund,
    refuseRefundById,
    confirmRefundById,
    seachDetailsById,
    updateRefuseById,
    batchRemove,
    getOrderReturns,
    deleteByIds,
    addCauseList,
    updataBUId,
    getRefundCount, getOrderApplyList,
    getfindById,
    delbatchRemoveById,
    getSearchObj,
    putConfirmRefundBy,
    putRefuseRefundBy,
    putUpdateRefuse,
    stateClassification,
    getExchangeCount,
    getOrderList,
    getSearchObjTwo,
    getOrderDetailList,
    getSkuById,
    OderUpdate,
    closeOrder,
    confirmOrder,
    batchconfirmOrder,
    getstate,
    btngetCount
}
